using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;

namespace Pavilion
{
    public class ArtificialKeyboard : IKeyboard
    {
        private List<Keys> keysPressed;

        public event Action<Keys[]> KeysPressed, KeysReleased;

        public ArtificialKeyboard()
        {
            keysPressed = new List<Keys>();
        }

        public void Update(GameTime gameTime) { }

        public void pressKey(Keys key)
        {
            //if (keyList.Contains(key) && !keysPressed.Contains(key))
            //{
            //    keysPressed.Add(key);
            //    OnKeyPressed(key);
            //}
        }

        public void releaseKey(Keys key)
        {
            //if (keysPressed.Contains(key))
            //{
            //    OnKeyReleased(key);
            //    keysPressed.Remove(key);
            //}
        }

        public bool GetKeyState(Keys key, bool isKeyDown)
        {
            if (isKeyDown)
            {
                if (keysPressed.Contains(key))
                    return true;
                else
                    return false;
            }
            else
            {
                if (!keysPressed.Contains(key))
                    return true;
                else
                    return false;
            }
        }

        private void OnKeysPressed(Keys[] keys)
        {
            if (KeysPressed != null)
                KeysPressed(keys);
        }

        private void OnKeysReleased(Keys[] keys)
        {
            if (KeysReleased != null)
                KeysReleased(keys);
        }
    }
}
